import request from '@/utils/request'
import type {
  AttrList,
  GetAttrListApiParams,
  saveUpdateAttrApiParams,
} from './model/attrModel'

enum Api {
  getAttrList = '/admin/product/attrInfoList',
  saveAttr = '/admin/product/saveAttrInfo',
  removeAttr = '/admin/product/deleteAttr',
}

// 获取属性列表
export const getAttrListApi = ({
  category1Id,
  category2Id,
  category3Id,
}: GetAttrListApiParams) => {
  return request.get<null, AttrList>(
    `${Api.getAttrList}/${category1Id}/${category2Id}/${category3Id}`
  )
}

// 添加属性
export const saveUpdateAttrApi = (data: saveUpdateAttrApiParams) => {
  return request.post<any, null>(Api.saveAttr, data)
}

// 删除属性
export const removeAttrApi = (id: number) => {
  return request.delete<any, null>(`${Api.removeAttr}/${id}`)
}
